package com.dhecp.project.hr.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.dhecp.common.core.domain.AjaxResult;
import com.dhecp.project.hr.domain.PositionInstructionsChild;
import com.dhecp.project.hr.mapper.PositionInstructionsJnMapper;
import com.dhecp.project.hr.service.PositionInstructionsJnService;

/**
 * 岗位说明书——技能技巧  业务实现层
 * @author lwl
 * @version 2020年2月26日
 */
@Service
public class PositionInstructionsJnServiceImpl implements PositionInstructionsJnService {

	@Autowired
	private PositionInstructionsJnMapper jnMapper;
	
	/**
	 * 根据nid查询信息
	 * @param params
	 * @return List-PositionInstructionsChild
	 * @author lwl
	 */
	@Override
	public List<PositionInstructionsChild> queryPositionInstructionsChildByNid(Map<String, Object> params) {
		// TODO Auto-generated method stub
		return jnMapper.findPositionInstructionsChildByNid(params);
	}

	/**
	 * 新增信息
	 * @param childItems
	 * @return MessageModel
	 * @author lwl
	 */
	@Override
	public AjaxResult insertPositionInstructionsChild(Map<String, Object> params) {
		// TODO Auto-generated method stub
		List<PositionInstructionsChild> childList = JSON.parseArray(params.get("childItems").toString(), PositionInstructionsChild.class);
        if (childList == null || childList.size() == 0) {
            return AjaxResult.error("数据包格式有误，请检查！");
        }
        for (PositionInstructionsChild child : childList) {
            
        	jnMapper.insertPositionInstructionsChild(child);
        }
        return AjaxResult.success("操作成功");
	}

	/**
	 * 根据nid删除信息
	 * @param 
	 * @return MessageModel
	 * @author lwl
	 */
	@Override
	public AjaxResult deletePositionInstructionsChildByNid(String nid) {
		// TODO Auto-generated method stub
		if (nid==null) {
			return AjaxResult.error("数据包格式有误，请检查！");
		}
		jnMapper.deletePositionInstructionsChildByNid(nid);
		return AjaxResult.success("操作成功！");
	}

}
